<template>
  <div>
    <el-tabs class="box">
      <el-tab-pane label="未读消息" name="first">
        <div
          class="wrap"
          v-for="(item, index) in list"
          :key="index"
          v-show="item.status == 0"
        >
          <span>{{ item.title }}</span>
          <el-button class="btn" @click="change1(item)">标记已读</el-button>
        </div>

        <el-button class="btn1" @click="allDone">全部标记为已读</el-button>
      </el-tab-pane>
      <el-tab-pane label="已读消息" name="second">
        <div
          class="wrap"
          v-for="(item, index) in list"
          :key="index"
          v-show="item.status == 1"
        >
          <span>{{ item.title }}</span>
          <div>
            <el-button @click="change3(item)">还原未读</el-button>
            <el-button @click="change2(item)">删除</el-button>
          </div>
        </div>
        <el-button class="btn1" @click="allchange">全部放入回收站</el-button>
      </el-tab-pane>
      <el-tab-pane label="回收站" name="third">
        <div
          class="wrap"
          v-for="(item, index) in list"
          :key="index"
          v-show="item.status == 2"
        >
          <span>{{ item.title }}</span>
          <el-button class="btn" @click="change1(item)">还原</el-button>
        </div>
        <el-button class="btn1" @click="allremove">全部删除</el-button>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: JSON.parse(localStorage.getItem("list")) || [
        {
          title: "瑞雪兆丰，祈迎百福。百厄除尽，万象更新。琼芳鹤舞。",
          status: 0,
        },
        {
          title: "劲风卷尘,涤荡百秽，扶摇破空 。百厄除尽,万象更新 。",
          status: 1,
        },
        {
          title: "百厄除尽,万象更新 。时雨降世，泽被百川。",
          status: 2,
        },
        {
          title: "列阵在北，玄武听命，，辟邪恶，调阴阳，，无人可见，无人能敌",
          status: 0,
        },
        {
          title:"麒麟踏祥云，人间百难消。临兵斗者皆列阵前行，无人可见，无人能敌。",
          status: 1,
        },
        {
          title:"撼天地，镇乾坤 ，衡山如飞，俯临万物!如月之恒，如日之升!天塌了，我顶着!",
          status: 2,
        },
        {
          title:"撼天地，镇乾坤，恒山如行，御风绝顶，星辰入怀!生如尘露，亦能折射朝阳之晖，其刚不可折，其柔不可卷",
          status: 0,
        },
        {
          title:
            "撼天地，镇乾坤，华山如立，不可摧折，鸿蒙既破!，屹立于此的，是历代传承之意志，通往太平之路，自古只有一条",
          status: 1,
        },
        {
          title:
            "撼天地，镇乾坤嵩山如卧，万物一府，一朝入梦，八极恣游~，浮云之上，九天之外，便是吾乡所在人非草木，安知草木无情?",
          status: 2,
        },
        {
          title:
            "撼天地，镇乾坤，泰山如坐，五岳独尊!岱宗如何!?天塌了，我顶着!威严的神明，不会轻易疯狂，我是你无法逾越的高峰!",
          status: 0,
        }
      ],
    };
  },
  mounted() {
    this.save();
  },
  methods: {
    save() {
      localStorage.setItem("list", JSON.stringify(this.list));
    },
    allDone() {
      this.list.forEach((item) => {
        if (item.status == 0) {
          item.status = 1;
        }
      });
      this.save();
    },
    allchange() {
      this.list.forEach((item) => {
        if (item.status == 1) {
          item.status = 2;
        }
      });
      this.save();
    },
    allremove() {
      this.list.forEach((item) => {
        if (item.status == 2) {
          item.status = -1;
        }
      });
      this.save();
    },
    change1(item) {
      item.status = 1;
      this.save();
    },
    change2(item) {
      item.status = 2;
      this.save();
    },
    change3(item) {
      item.status = 0;
      this.save();
    },
  },
};
</script>
<style scoped>
.box {
  margin-top: 10px;
  margin-left: 50px;
}
.wrap {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #ccc;
  height: 60px;
  line-height: 50px;
}
.btn {
  height: 40px;
}
.btn1 {
  margin-left: -1000px;
}
</style>